// /import React from 'react'
import axios from "axios"
import { Button } from "antd"
import { useState } from "react"
import md5 from "md5"
function Yd() {
  const [data,setData]=useState()
  const [list,setList]=useState()
  const fy = () => {
    const salt=new Date().getTime()
const sign=md5('09da0022d07561a9'+data+salt+'vENm4jsKM8bwLYSiXGKiDl18rOg8wWC0')
    axios.get('/yd-api/api', {
      params: {
        q: data,
        from: 'auto',
        to: 'en',
        appKey: '09da0022d07561a9',
        salt,
        sign,
      }
    }).then(res=>{
   console.log(res);
   setList(res.data.translation[0])
   
    })
  }


  return (
    <div>
      <input placeholder="请输入内容" onChange={(e)=>setData(e.target.value)}></input>
      <Button onClick={fy}>翻译</Button>
      <div>
        {list}
      </div>
    </div>
  )
}

export default Yd
